/**
 * @Description: 工具函数集合
 * @author QianZhou Xu
 * @date 2023/9/7
 */
import { prefixStorage } from '@renderer/common/constant'

/**
 * 写入localstorage
 * @param params
 */
export const setStorage = (params) => {
  Object.keys(params).forEach((_k) => {
    localStorage.setItem(`${prefixStorage}${_k}`, params[_k])
  })
}

/**
 * 读取localstorage
 * @param keys
 */
export const getStorage = (keys) => {
  let obj = {}
  keys.forEach((_v) => {
    obj[_v] = localStorage.getItem(`${prefixStorage}${_v}`)
  })
  return obj
}

/**
 * 获取Lcu请求头
 */
export const getLcuHeader = () => {
  const _s = getStorage(['token'])
  return {
    Accept: '*/*',
    mode: 'cors',
    'Content-Type': 'application/json;charset=utf-8',
    Authorization: _s?.token
  }
}
